package com.wwtech.epp.ui.adapter.work;

import android.support.annotation.Nullable;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.wwtech.epp.R;
import com.wwtech.epp.entity.Comment;
import com.wwtech.epp.view.GlideCircleTransform;

import java.util.List;

/**
 * Created by hu on 2017/10/12.
 */

public class CommentListAdapter extends BaseQuickAdapter<Comment.DataBean.ListBean, BaseViewHolder> {

    public CommentListAdapter(@Nullable List<Comment.DataBean.ListBean> data) {
        super(R.layout.item_project_comment, data);
    }

    @Override
    protected void convert(BaseViewHolder baseViewHolder, Comment.DataBean.ListBean listBean) {
        baseViewHolder.setText(R.id.name, listBean.getNickName())
                .setText(R.id.content, listBean.getContent())
                .setText(R.id.title, listBean.getOrgTitle())
                .setText(R.id.time, listBean.getCreateTime().substring(0, 11));
        TextView content = baseViewHolder.getView(R.id.content);
        ImageView imageView = baseViewHolder.getView(R.id.avater);
        Glide.with(mContext)
                .load(listBean.getAvatar())
                .transform(new GlideCircleTransform(mContext))
                .into(imageView);
        baseViewHolder.setVisible(R.id.view, baseViewHolder.getLayoutPosition() == 0? false : true);
        switch (listBean.getRoleLevel()) {
            case 1:
                content.setTextColor(mContext.getResources().getColor(R.color.color_999));
                break;
            case 2:
                content.setTextColor(mContext.getResources().getColor(R.color.color_new_task));
                break;
            case 3:
                content.setTextColor(mContext.getResources().getColor(R.color.color_f51818));
                break;
        }
    }
}
